<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>编辑页面</title>
	<link rel="stylesheet" href="http://shop.com:5500/resources/css/back.css" />
	<script src="http://shop.com:5500/resources/js/jquery-1.11.3.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="http://shop.com:5500/resources/js/jquery-heima-0.0.1.js"></script>
</head>
<script>
	// 页面加载成功
	$(function () {
		// 拿到地址栏的参数，cid
		var cid = HM.getParameter("cid");
		// alert(cid);
		// 发请求
		$.ajax({
			url: "http://api.shop.com:8080/category?md=findById",
			type: "get",
			data: { cid: cid },
			success: function (response) {
				// alert(response);
				// 字符串转对象
				var category = eval("(" + response + ")");
				// alert(category.data);
				$("#cname").val(category.data.cname);
			}

		});
	})
	// 修改 分类信息
	// 绑定事件
	function updateCategory() {
		// var cid = HM.getParameter("cid");
		var cname = $("#cname").val();
		// 拿到地址栏的，cid
		var cid = HM.getParameter("cid");
		alert(cname);
		alert(cid);

		$.ajax({
			url: "http://api.shop.com:8080/category?md=update" + "&cid=" + cid + "&cname=" + cname,
			type: "get",
			// data: { cid: cid, cname: cname },
			success: function (response) {
				alert(response);
				//跳转列表页面展示
				// location.href="category/list.html";
			}
		});
	}
</script>

<body>
	<form method="post">
		<table cellSpacing="1" cellPadding="5" width="100%" align="center" bgColor="#eeeeee"
			style="border: 1px solid #8ba7e3" border="0">
			<tr>
				<td class="ta_01" align="center" bgColor="#afd1f3" colSpan="4" height="26">
					<STRONG>编辑分类</STRONG>
				</td>
			</tr>

			<tr>
				<td width="18%" align="center" bgColor="#f5fafe" class="ta_01">
					分类名称：
				</td>
				<td class="ta_01" bgColor="#ffffff" colspan="3">
					<input type="text" name="cname" id="cname" class="bg" />
				</td>
			</tr>

			<tr>
				<td class="ta_01" style="WIDTH: 100%" align="center" bgColor="#f5fafe" colSpan="4">
					<!-- 保存按钮 -->
					<button type="submit" id="save" value="修改" class="button_ok" onclick="updateCategory()">
						&#30830;&#23450;
					</button>

					<!-- <FONT face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>
					<button type="reset" value="重置" class="button_cancel">&#37325;&#32622;</button> -->

					<FONT face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT>
					<INPUT class="button_ok" type="button" onclick="history.go(-1)" value="返回" />
					<span id="Label1"></span>
				</td>
			</tr>
		</table>
	</form>
</body>

</html>